﻿using System;
using System.Linq;
using LINQPad.OpenAccess.Helpers;
using Telerik.OpenAccess.Metadata;

namespace LINQPad.OpenAccess.Data
{
    /// <summary>
    /// Backend-Provider Mapping
    /// </summary>
    public class BackendProviderMapping
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BackendProviderMapping" /> class.
        /// </summary>
        /// <param name="backend">The backend.</param>
        /// <param name="backendConfigName">Name of the backend config.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="isDefault">set to <c>true</c> if its the default mapping for the <paramref name="backend"/>.</param>
        public BackendProviderMapping( Backend backend, string backendConfigName, string providerName, bool isDefault = false )
        {
            Guard.ArgumentNotNullOrEmpty( backendConfigName, "backendConfigName" );
            Guard.ArgumentNotNullOrEmpty( providerName, "providerName" );

            this.Backend = backend;
            this.BackendConfigName = backendConfigName;
            this.ProviderName = providerName;
            this.IsDefault = isDefault;
        }
        /// <summary>
        /// Gets the backend.
        /// </summary>
        /// <value>
        /// The backend.
        /// </value>
        public Backend Backend { get; private set; }
        /// <summary>
        /// Gets the config name of the backend.
        /// </summary>
        /// <value>
        /// The the config name of the backend config.
        /// </value>
        public string BackendConfigName { get; private set; }
        /// <summary>
        /// Gets a value indicating whether this mapping is the default one for the specified backend.
        /// </summary>
        /// <value>
        /// <c>true</c> if this mapping is the default one for the specified backend; otherwise, <c>false</c>.
        /// </value>
        public bool IsDefault { get; private set; }
        /// <summary>
        /// Gets the name of the provider.
        /// </summary>
        /// <value>
        /// The name of the provider.
        /// </value>
        public string ProviderName { get; private set; }
    }
}
